
/**
 * <p>Copyright： 东软烟草产品研发团队</p>   
 */

package com.jkl.service.project;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.http.HttpUtil;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.entity.dept.Dept;
import com.jkl.entity.param.ParamKey;
import com.jkl.entity.project.dto.VillageDTO;
import com.jkl.entity.project.po.*;
import com.jkl.entity.project.vo.*;
import com.jkl.service.param.ParamKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jkl.comm.service.FileService;
import com.jkl.dao.dept.BSDeptMapper;
import com.jkl.dao.project.PJProjectMapper;
import com.jkl.dao.project.PJProjectReportMapper;
import com.jkl.entity.bsAddition.BsAddition;
import com.jkl.entity.bsWorkflowLog.BsWorkflowLog;
import com.jkl.entity.dept.BSDept;
import com.jkl.entity.drTable.DrTable;
import com.jkl.entity.drTableDetail.DrTableDetail;
import com.jkl.entity.param.BSParam;
import com.jkl.entity.project.dto.ProjectInfoDTO;
import com.jkl.entity.project.extend.PJVillage;

import com.jkl.entity.role.BsRole;
import com.jkl.service.project.inter.IPJProjectLogService;
import com.jkl.service.project.inter.IPJProjectPictureService;
import com.jkl.service.project.inter.IPJProjectService;
import com.jkl.service.projectNew.inter.IProjectNewService;

import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;

/**
 * <p>
 * 123service
 * <p>
 * <p>
 * 123service
 * <p>
 * <p>
 * 变更说明：ji.k 2018年1月17日 123service
 * <p>
 * Date:2018年10月01日
 *
 * @author ji.k
 * @version 1.0
 */
@Slf4j
@Service
public class PJProjectService implements IPJProjectService {

	@Autowired
	private PJProjectMapper pJProjectMapper;
	@Autowired
	private IPJProjectPictureService pjProjectPictureService;
	@Autowired
	private PJProjectReportMapper projectReportMapper;
	@Autowired
	private IPJProjectLogService projectLogService;
	@Autowired
	private IProjectNewService projectNewService;
	@Autowired
	private ParamKeyService paramKeyService;


	@Autowired
	private BSDeptMapper bSDeptMapper;
	@Autowired
	private FileService fileService;
/*	@Override
	public int addProject(PJProject projetInfo, List<MultipartFile> fileList) {
		pJProjectMapper.addProject(projetInfo);
		Integer projectId = projetInfo.getRowId();
		pjProjectPictureService.addProjectPicture(1, projectId, fileList);
		// 状态为2 提交审核
		// 添加提交日志
		if (projetInfo.getStatus().equals( "2")) {
			// 添加日志
			if (CollectionUtils.isEmpty(fileList)) {
				addProjectLog(projetInfo, "项目新增", 1, 0);
			} else {
				addProjectLog(projetInfo, "项目新增", 1, 1);
			}

		}
		return projectId;
	}*/

/*	public void addProjectLog(PJProject projetInfo, String content, int logType, int isPicture) {
		PJProjectLog projectLog = new PJProjectLog();
		projectLog.setProjectId(projetInfo.getRowId()).setLogType(logType).setLogFrom("PJ_PROJECT")
				.setRecordId(projetInfo.getRowId()).setProjectContent(content).setPersonId(projetInfo.getPersonId())
				.setIsPicture(isPicture).setOperDate(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));

		projectLogService.addProjectLig(projectLog);
	}*/

	/*
	 * (non-Javadoc) 新增页面提交
	 */
/*	@Override
	public void submitProject(PJProject projetInfo, List<MultipartFile> fileList) {
		pJProjectMapper.updateProject(projetInfo);
		PJProjectPicture deletePicture = new PJProjectPicture();
		deletePicture.setRecordId(projetInfo.getRowId()).setPicType(1);
		// 图片先删除再新增
		pjProjectPictureService.deletePictureByRecordId(deletePicture);
		pjProjectPictureService.addProjectPicture(1, projetInfo.getRowId(), fileList);
		// 添加日志
		if (CollectionUtils.isEmpty(fileList)) {
			addProjectLog(projetInfo, "项目新增", 1, 0);
		} else {
			addProjectLog(projetInfo, "项目新增", 1, 1);
		}
	}*/

	@Override
	public JSONObject queryProjectInfoById(String projectId) {
		ProjectInfoDTO projectInfo = pJProjectMapper.queryProjectInfoById(projectId);
		PJProjectPicture queryRecord = new PJProjectPicture();
		queryRecord.setPicType(1).setRecordId(Integer.parseInt(projectId));
		List<PJProjectPicture> picList = pjProjectPictureService.getMapper().select(queryRecord);
		projectInfo.setPictureList(picList);
		JSONObject returnData = (JSONObject) JSON.toJSON(projectInfo);
		return returnData;
	}

/*	@Override
	public void updateProjectInf(PJProject projetInfo, List<PJProjectPicture> delePictureList,
			List<MultipartFile> fileList) {
		// 更新projectInfo数据
		pJProjectMapper.updateByPrimaryKey(projetInfo);
		// 新增图片
		pjProjectPictureService.addProjectPicture(1, projetInfo.getRowId(), fileList);
		// 需要删除的图片
		for (PJProjectPicture picture : delePictureList) {
			pjProjectPictureService.deleteByEntity(picture);
		}
		if (projetInfo.getStatus() == 2) {
			// 状态为2是提交,需要添加日志
			if (CollectionUtils.isEmpty(fileList)) {
				addProjectLog(projetInfo, "项目新增", 1, 0);
			} else {
				addProjectLog(projetInfo, "项目新增", 1, 1);
			}
		}
	}

	@Override
	public void ctiyAuditProject(PJProject projectInfo) {
		pJProjectMapper.updateCtiyAudit(projectInfo);
		addProjectLog(projectInfo, projectInfo.getCityIdea(), 2, 0);
	}

	@Override
	public void provinceAuditProject(PJProject projectInfo) {
		pJProjectMapper.updateProvinceAudit(projectInfo);
		addProjectLog(projectInfo, projectInfo.getProvinceIdea(), 3, 0);
	}*/

	@Override
	public void projectReport(ProjectReportVO projectReportVO, List<MultipartFile> fileList) {

		PJProjectReport projectReport = new PJProjectReport();
		projectReport.setProjectId(projectReportVO.getProjectId()).setReportContent(projectReportVO.getContent())
				.setReportDate(LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE)).setStatus(1);
		projectReportMapper.addProjectReport(projectReport);
		Integer projectId = projectReport.getRowId();
		pjProjectPictureService.addProjectPicture(2, projectReport.getRowId(), fileList);

		if (projectReportVO.getIsComplete() == 5) {
			// 项目竣工,将projectstatus更新为5
			pJProjectMapper.updateStatusTo5(projectReportVO.getProjectId());
		}
		// 添加日志
		PJProjectLog projectLog = new PJProjectLog();
		projectLog.setProjectId(projectReportVO.getProjectId()).setLogType(projectReportVO.getIsComplete())
				.setLogFrom("PJ_PROJECT_REPORT").setRecordId(projectReport.getRowId())
				.setProjectContent(projectReport.getReportContent()).setPersonId(projectReportVO.getPersonId())
				.setOperDate(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
		if (CollectionUtils.isEmpty(fileList)) {
			projectLog.setIsPicture(0);
		} else {
			projectLog.setIsPicture(1);
		}
		projectLogService.addProjectLig(projectLog);
	}

	@Override
	public JSONObject queryProjectLogByProjectId(String projectId) {
		List<PJProjectLog> projectLogList = projectLogService.findByProjectId(Integer.parseInt(projectId));
		for (PJProjectLog log : projectLogList) {
			if (log.getIsPicture() == 1) {
				PJProjectPicture queryRecord = new PJProjectPicture();
				queryRecord.setRecordId(log.getRecordId());
				if (log.getLogType() == 1) {
					queryRecord.setPicType(1);
				} else if (log.getLogType() == 4) {
					queryRecord.setPicType(2);
				}
				List<PJProjectPicture> picList = pjProjectPictureService.getMapper().select(queryRecord);
				log.setPictureList(picList);
			}
		}
		JSONObject returnJson = new JSONObject();
		JSONArray logArray = (JSONArray) JSONArray.toJSON(projectLogList);
		returnJson.put("projectLogList", logArray);
		return returnJson;
	}

	@Override
	public PageInfo<PJProject> queryProjectByparams(PJProject param) {
		PageHelper.startPage(param.getCurrentPage(), param.getPageSize());
		List<PJProject> list = pJProjectMapper.queryProjectByparams(param);
		PageInfo<PJProject> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public PageInfo<BSParam> queryInit(String groupCode) {
		List<BSParam> list = pJProjectMapper.queryInit(groupCode);
		PageInfo<BSParam> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public Boolean deleteById(PJProject pjProject) {
		try {
			Example example = new Example(PJProject.class);
			example.createCriteria().andEqualTo("rowId", pjProject.getRowId());
			pJProjectMapper.updateByExampleSelective(pjProject.setStatus("0"), example);
			return true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return false;
	}

	@Override
	public List<ProjectEcharts> getProjectEcharts(ProjectEcharts projectEcharts) {
		return pJProjectMapper.getProjectEcharts(projectEcharts);
	}

/*	@Override
	public IndexCharts getIndexCharts(IndexCharts indexCharts) {
		IndexCharts returnData = new IndexCharts();
		List<PJProject> citys = new ArrayList<>();
		List<PJProject> counties = new ArrayList<>();
		List<Float> index1 = new ArrayList<>();
		List<String> index2 = new ArrayList<>();
		List<String> names = new ArrayList<>();
		if (indexCharts.getLevel() == 1) {
			// 市级 汇总
			List<PJIndex> indexs = pJProjectMapper.getIndex(2, 0, indexCharts.getYear());
			// citys = pJProjectMapper.getIndexCharts(indexCharts.setLevel(2));
			counties = pJProjectMapper.getIndexCharts(indexCharts.setLevel(3));
			for (PJIndex index : indexs) {
				Float total = (float) 0;
				for (int i = 0; i < counties.size(); i++) {
					PJProject project = counties.get(i);
					if (project.getParentId() == null || index.getDeptId() == null) {
					} else {
						if (project.getParentId().intValue() == index.getDeptId().intValue()) {
							total = project.getTotalArea() + total;
							counties.remove(i);
						}
					}
				}
				// for (int i = 0; i < citys.size(); i++){
				// if (index.getDeptId() == null || citys.get(i).getAreaId() ==
				// null) {
				// } else {
				// if (index.getDeptId().intValue() ==
				// citys.get(i).getAreaId().intValue()) {
				// total = citys.get(i).getTotalArea() + total;
				// citys.remove(i);
				// }
				// }
				// }

				names.add(index.getDeptName());
				index1.add(total / 10000);
				if (indexCharts.getProjectNatures().size() == 0 && indexCharts.getDecorateStatus() == 0) {
					if (index.getFitArea() == null)
						index2.add("0");
					else
						index2.add(index.getFitArea());
				} else if (indexCharts.getProjectNatures().size() > 0 && indexCharts.getDecorateStatus() == 0) {
					if (index.getFitPublicArea() == null)
						index2.add("0");
					else
						index2.add(index.getFitPublicArea());
				} else {
					if (index.getDecorateArea() == null)
						index2.add("0");
					else
						index2.add(index.getDecorateArea());
				}
			}
		} else {
			// 县级 汇总
			List<PJIndex> indexs = pJProjectMapper.getIndex(3, indexCharts.getDeptId(), indexCharts.getYear());
			counties = pJProjectMapper.getIndexCharts(indexCharts.setLevel(3));
			for (int j = 0; j < indexs.size(); j++) {
				PJIndex index = indexs.get(j);
				if (indexCharts.getProjectNatures().size() == 0 && indexCharts.getDecorateStatus() == 0) {
					if (index.getFitArea() == null)
						index2.add("0");
					else
						index2.add(index.getFitArea());
				} else if (indexCharts.getProjectNatures().size() > 0 && indexCharts.getDecorateStatus() == 0) {
					if (index.getFitPublicArea() == null)
						index2.add("0");
					else
						index2.add(index.getFitPublicArea());
				} else {
					if (index.getDecorateArea() == null)
						index2.add("0");
					else
						index2.add(index.getDecorateArea());
				}
				names.add(index.getDeptName());
				for (int i = 0; i < counties.size(); i++) {
					PJProject project = counties.get(i);
					if (project.getParentId() == null || index.getDeptId() == null) {
					} else {
						if (project.getDeptId().intValue() == index.getDeptId().intValue()) {
							index1.add(project.getTotalArea() / 10000);
							counties.remove(i);
						}
					}
				}
				if (index1.size() < j + 1) {
					index1.add((float) 0);
				}
			}
		}
		returnData.setNames(names);
		returnData.setIndex1(index1);
		returnData.setIndex2(index2);
		return returnData;
	}*/

	@Override
	public String getProjectCode(String deptId) {
		Example example1 = new Example(BSDept.class);
		example1.createCriteria().andEqualTo("rowId", Long.parseLong(deptId));
		List<BSDept> dept = bSDeptMapper.selectByExample(example1);
		String prefix = dept.get(0).getProjectNo();
		String dateTime = new SimpleDateFormat("yyyyMMdd").format(new Date());
		String num = pJProjectMapper.getProjectSumByDept(deptId, dateTime);
		if (num.length() == 1) {
			num = "0" + num;
		}
		return prefix + dateTime + num;
	}

	//车start
	@Override//列表
	public PageInfo<PJProjectCar> queryCarProject(PJProjectCar param) {
		PageHelper.startPage(param.getCurrentPage(), param.getPageSize());
		List<PJProjectCar> list = pJProjectMapper.queryCarProject(param);
		for (int i = 0; i < list.size(); i++) {
			List<PJProjectCarRelationship> pjProjectCarRelationshipList = pJProjectMapper.queryCarTransportRoutes(String.valueOf(list.get(i).getRowId()));
			if(pjProjectCarRelationshipList.size() != 0) {
				String sourceName = "";
				String destName = pjProjectCarRelationshipList.get(0).getDestName();
				for (int j = 0; j < pjProjectCarRelationshipList.size(); j++) {
					if(j != 0) {
						sourceName = sourceName + "-" + pjProjectCarRelationshipList.get(j).getSourceName();
					}else {
						sourceName = pjProjectCarRelationshipList.get(j).getSourceName();
					}
				}
				list.get(i).setSourceRoute(sourceName);
				list.get(i).setDestRoute(destName);
			}
		}
		PageInfo<PJProjectCar> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}
	@Override//新增
	public int addCarProject(PJProjectCar param) {
		return pJProjectMapper.addCarProject(param);
	}

	@Override
	public PJProjectCar queryCarObject(String projectId) {
		return pJProjectMapper.queryCarObject(projectId);
	}
	@Override//修改
	public int updateCarProject(PJProjectCar param) {
		return pJProjectMapper.updateCarProject(param);
	}
	//车end

	//效绩考核
	@Override//列表
	public PageInfo<PJProjectIndexSetting> queryIndexSetting(PJProjectIndexSetting param) {
		PageHelper.startPage(param.getCurrentPage(), param.getPageSize());
		List<PJProjectIndexSetting> list = pJProjectMapper.queryIndexSetting(param);
		PageInfo<PJProjectIndexSetting> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}
	@Override//单个
	public PJProjectIndexSetting queryIndexSettingObject(String projectId) {
		return pJProjectMapper.queryIndexSettingObject(projectId);
	}

	//绩效考核end
	//站start
	//@Override//列表
	/*public PageInfo<PJProjectNew> queryProjectByparamsNew(PJProjectNew param) {
		PageHelper.startPage(param.getCurrentPage(), param.getPageSize());
		List<PJProjectNew> list = pJProjectMapper.queryProjectByparamsNew(param);
		PageInfo<PJProjectNew> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}*/
	@Override
	public PageInfo<PJProject> queryProjectByparamsNew(PJProject param) {
		PageHelper.startPage(param.getCurrentPage(), param.getPageSize());
		//List<Integer> deptIdList = queryVillageWithAll(param.getSelectDeptId());
		//param.setDeptIdList(deptIdList);
		List<PJProject> list = pJProjectMapper.queryProjectByparamsNew(param);
//		System.out.print(list);
		PageInfo<PJProject> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public PageInfo<PJProject> queryProjectByparamsVillage(PJVillage param) {
		PageHelper.startPage(param.getCurrentPage(), param.getPageSize());
		//List<Integer> deptIdList = queryVillageWithAll(param.getSelectDeptId());
		//param.setLastDeptList(deptIdList);
		List<PJProject> list = pJProjectMapper.queryProjectByparamsVillage(param);
//		System.out.print(list);
		PageInfo<PJProject> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	private List<Integer> queryVillageWithAll( int param){
		HashMap<String, Object> map = new HashMap<>();
		List<Integer> deptIdList = new ArrayList<>();
		map.put("deptId",param);
		map.put("level",6);
		String deptIdStr = HttpUtil.get("http://111.1.30.208:8090/api/v1/admin/bsdept/nextdept", map);
		JSONObject jsonObject = JSON.parseObject(deptIdStr);
		JSONArray result = jsonObject.getJSONArray("result");
		for (Object i : result) {
			deptIdList.add((Integer) i);
		}
		return deptIdList;
	}


	@Override
	public int addVillageProject(PJProject param) {
		return pJProjectMapper.addVillageProject(param);
	}

	@Override
	public int saveCarTransportRoutes(PJProjectCarVO param) {
		PJProjectCarRelationship pjProjectCarRelationship = new PJProjectCarRelationship();
		List<PJProject> terminusStation = param.getTerminusStation();
		List<PJProject> originatingStation = param.getOriginatingStation();
		for (int i = 0; i < originatingStation.size(); i++) {
			pjProjectCarRelationship.setVehicleId(param.getVehicleId());
			pjProjectCarRelationship.setVehicleName(param.getVehicleName());
			pjProjectCarRelationship.setSourceId(originatingStation.get(i).getRowId());
			pjProjectCarRelationship.setSourceName(originatingStation.get(i).getProjectName());
			pjProjectCarRelationship.setDestId(terminusStation.get(0).getRowId());
			pjProjectCarRelationship.setDestName(terminusStation.get(0).getProjectName());
			pjProjectCarRelationship.setStatus("1");
			pJProjectMapper.saveCarTransportRoutes(pjProjectCarRelationship);
		}
		return 0;
	}
	// 查询车辆路线
	@Override
	public BaseResponseDTO queryCarTransportRoutes(String vehicleId) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		List<PJProject> pjProjectDestList = new ArrayList<>();
		List<PJProject> pjProjectSourceList = new ArrayList<>();
		List<PJProjectCarRelationship> pjProjectCarRelationshipList = pJProjectMapper.queryCarTransportRoutes(vehicleId);
		if(pjProjectCarRelationshipList.size() != 0) {
			for (int i = 0; i < pjProjectCarRelationshipList.size(); i++) {
				PJProject pjProject = new PJProject();
				pjProject.setRowId(pjProjectCarRelationshipList.get(i).getSourceId());
				pjProject.setProjectName(pjProjectCarRelationshipList.get(i).getSourceName());
				pjProjectSourceList.add(pjProject);
			}
			PJProject pjProject = new PJProject();
			pjProject.setRowId(pjProjectCarRelationshipList.get(0).getDestId());
			pjProject.setProjectName(pjProjectCarRelationshipList.get(0).getDestName());
			pjProjectDestList.add(pjProject);
		}
		JSONObject returnJson = new JSONObject();
		returnJson.put("sourceList", pjProjectSourceList);
		returnJson.put("destList", pjProjectDestList);

		returnData.setReturnData(returnJson);
		return returnData;
	}
	// 保存之前，删除之前所保存的路线
	@Override
	public void deleteCarTransportRoutes(String vehicleId) {
		pJProjectMapper.deleteCarTransportRoutes(vehicleId);
	}

	// 初始车辆的信息
	@Override
	public BaseResponseDTO initCarData() {
		BaseResponseDTO returnData = new BaseResponseDTO();
		int carNums = pJProjectMapper.initCarNums();  // 车辆总数
		List<CarProjectVO> carDistribution = pJProjectMapper.initCarDistribution(); // 车辆分布

		List<CarProjectVO> carLink = pJProjectMapper.initVehicleLink();  // 运输环节

		List<CarProjectVO> carTransportType = pJProjectMapper.initTransportType(); // 运输类型

		List<CarProjectVO> carTon = pJProjectMapper.initCarTon(); // 车辆吨位

		JSONObject returnJson = new JSONObject();
		returnJson.put("carNums", carNums);
		returnJson.put("carLink", carLink);
		returnJson.put("carDistribution", carDistribution);
		returnJson.put("carTransportType", carTransportType);
		returnJson.put("carTon", carTon);
		returnData.setReturnData(returnJson);
		return returnData;
	}
	// 通过id初始化车辆的信息
	@Override
	public BaseResponseDTO initCarDataById(String deptId) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		int carNums = pJProjectMapper.initCarNumsById(deptId);  // 车辆总数
		List<CarProjectVO> carDistribution = pJProjectMapper.initCarDistributionById(deptId); // 车辆分布
		System.out.println(carDistribution);
		List<CarProjectVO> carLink = pJProjectMapper.initVehicleLinkById(deptId);  // 运输环节
		System.out.println(carLink);
		List<CarProjectVO> carTransportType = pJProjectMapper.initTransportTypeById(deptId); // 运输类型
		System.out.println(carTransportType);
		List<CarProjectVO> carTon = pJProjectMapper.initCarTonById(deptId); // 车辆吨位
		System.out.println(carTon);
		JSONObject returnJson = new JSONObject();
		returnJson.put("carNums", carNums);
		returnJson.put("carLink", carLink);
		returnJson.put("carDistribution", carDistribution);
		returnJson.put("carTransportType", carTransportType);
		returnJson.put("carTon", carTon);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	@Override
	public Integer delCarProjectById(String carId) {
		return pJProjectMapper.delCarProjectById(carId);
	}



	@Override
	public List<PJProject> queryProjectListByParam(PJProject param) {

		List<PJProject> list = pJProjectMapper.queryProjectListByParam(param);
		return list;
	}

	@Override//主表单个查询
	public PJProjectNew queryProjectNew(int rowId) {
		return pJProjectMapper.queryProjectNew(rowId);
	}

	@Override//主表更新
	public int updateProjectNew(PJProjectNew projectNew) {
		return pJProjectMapper.updateProjectNew(projectNew);
	}

	@Override//改变状态
	public int updateStatus(String rowId, String Status) {
		return pJProjectMapper.updateStatus(rowId,Status);
	}

	@Override//新增
	public int addPJProjectNew(PJProjectNew param) {
		return pJProjectMapper.addPJProjectNew(param);
	}


	@Override
	public int addBurn(PJProjectBurn param, List<MultipartFile> fileList) {
		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());
		pJProjectMapper.addBurn(param);
		int rowId = pJProjectMapper.selectRowId("103");
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}

	@Override
	public PJProjectBurn queryBurn(String projectId) {
		PJProjectBurn pJProjectBurn = pJProjectMapper.queryBurn(projectId);
		//LastData lastData = pJProjectMapper.queryLast(projectId);
		/*if (null != lastData) {
			pJProjectBurn.setLastCivilEngineering(lastData.getLastCivilEngineering());
			pJProjectBurn.setLastEquipmentInstall(lastData.getLastEquipmentInstall());
			pJProjectBurn.setLastPopulation(lastData.getLastPopulation());
			pJProjectBurn.setLastReportMonth(lastData.getLastReportMonth());
		}*/
		return pJProjectBurn;
	}

	@Override
	public void updateBurn(PJProjectBurn param, List<MultipartFile> fileList) {
		pJProjectMapper.updateBurn(param);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(param.getRowId());
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		pJProjectMapper.updateWorkflowLog(param.getRowId(), param.getLastMoney());
	}



	@Override
	public int addKitchen(PJProjectKitchen param, List<MultipartFile> fileList) {

		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());

		pJProjectMapper.addKitchen(param);
		int rowId = pJProjectMapper.selectRowId("104");
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}
	@Override
	public PJProjectKitchen queryKitchen(String projectId) {
		PJProjectKitchen pJProjectKitchen = pJProjectMapper.queryKitchen(projectId);
		/*LastData lastData = pJProjectMapper.queryLast(projectId);
		if (null != lastData) {
			pJProjectKitchen.setLastCivilEngineering(lastData.getLastCivilEngineering());
			pJProjectKitchen.setLastEquipmentInstall(lastData.getLastEquipmentInstall());
			pJProjectKitchen.setLastPopulation(lastData.getLastPopulation());
			pJProjectKitchen.setLastReportMonth(lastData.getLastReportMonth());
		}*/
		return pJProjectKitchen;
	}
	@Override
	public void updateKitchen(PJProjectKitchen param, List<MultipartFile> fileList) {
		pJProjectMapper.updateKitchen(param);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(param.getRowId());
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		pJProjectMapper.updateWorkflowLog(param.getRowId(), param.getLastMoney());
	}






	@Override//经纬度--查询单个
	public PJProjectAddCoordinate queryCoordinate(String projectId) {
		return pJProjectMapper.queryCoordinate(projectId);
	}
	@Override//经纬度--查询全部
	public List<PJProjectNew> queryCoordinateAll(PJProjectNew param) {
		return pJProjectMapper.queryCoordinateAll(param);
	}
	@Override
	public int updateCoordinate(PJProject param) {
		return pJProjectMapper.updateCoordinate(param);
	}



	@Override//列表
	public List<StatisticsSiteType> statisticsSiteType(StatisticsSiteType param) {
		return pJProjectMapper.statisticsSiteType(param);
	}


	@Override//获取id
	public int getRowId() {
		return pJProjectMapper.getRowId();
	}
	//站end

	//首页start
	@Override
	public List<HomePageLeft> homePageLeft(String homePageName) {
		return pJProjectMapper.homePageLeft(homePageName);
	}
	@Override
	public List<HomePageLeft> homePageLine(String homePageName) {
		return pJProjectMapper.homePageLine(homePageName);
	}
	//首页end

	@Override
	public int putLog(SljptLog param) {
		return pJProjectMapper.putLog(param);
	}

	@Override
	public int getImport(List<DrTable> param) {
		int a=0;
		for(DrTable drtable :param) {
			int b=pJProjectMapper.getImport(drtable);
			if(b==1) {
				a++;
			}
			for(DrTableDetail drTableDetail :drtable.getDrTableDetailList()) {
				pJProjectMapper.getImportDetail(drTableDetail);
			}
		}
		return a;
	}

	@Override
	public int indexImport(List<XljptIndexImport> param) {
		List<Integer> a=pJProjectMapper.findRowId();
		if(a.size()==0) {
			for(int i=0;i<param.size();i++) {
				XljptIndexImport xljptIndexImport =new XljptIndexImport();
				XljptIndexImport xljptIndexImport2 =new XljptIndexImport();
				xljptIndexImport.setRowId(param.get(i).getRowId());
				xljptIndexImport.setIndexCode(param.get(i).getIndexCode());
				xljptIndexImport.setIndexName(param.get(i).getIndexName());
				xljptIndexImport.setType(param.get(i).getType());
				xljptIndexImport.setTypeLevel(param.get(i).getTypeLevel());
				xljptIndexImport.setLevel(param.get(i).getLevel());
				xljptIndexImport.setLink(param.get(i).getLink());
				xljptIndexImport.setCycle(param.get(i).getCycle());
				xljptIndexImport.setUnit(param.get(i).getUnit());
				xljptIndexImport.setRemark(param.get(i).getRemark());
				xljptIndexImport.setIsHand(param.get(i).getIsHand());
				xljptIndexImport.setPersonId(param.get(i).getPersonId());
				xljptIndexImport.setOperTime(param.get(i).getOperTime());
				xljptIndexImport.setStatus(param.get(i).getStatus());
				xljptIndexImport.setDataType(param.get(i).getDataType());
				xljptIndexImport.setScope(param.get(i).getScope());
				pJProjectMapper.indexImport(xljptIndexImport);
				xljptIndexImport2.setRowId(param.get(i).getRowId2());
				xljptIndexImport2.setIndexCode2(param.get(i).getIndexCode2());
				xljptIndexImport2.setFormulaNote(param.get(i).getFormulaNote());
				xljptIndexImport2.setIndexFormula(param.get(i).getIndexFormula());
				pJProjectMapper.indexImporDetail(xljptIndexImport2);
			}
		}else {
			pJProjectMapper.deleteIndex();
			pJProjectMapper.deleteIndexDetail(a);
			for(int i=0;i<param.size();i++) {
				XljptIndexImport xljptIndexImport =new XljptIndexImport();
				XljptIndexImport xljptIndexImport2 =new XljptIndexImport();
				xljptIndexImport.setRowId(param.get(i).getRowId());
				xljptIndexImport.setIndexCode(param.get(i).getIndexCode());
				xljptIndexImport.setIndexName(param.get(i).getIndexName());
				xljptIndexImport.setType(param.get(i).getType());
				xljptIndexImport.setTypeLevel(param.get(i).getTypeLevel());
				xljptIndexImport.setLevel(param.get(i).getLevel());
				xljptIndexImport.setLink(param.get(i).getLink());
				xljptIndexImport.setCycle(param.get(i).getCycle());
				xljptIndexImport.setUnit(param.get(i).getUnit());
				xljptIndexImport.setRemark(param.get(i).getRemark());
				xljptIndexImport.setIsHand(param.get(i).getIsHand());
				xljptIndexImport.setPersonId(param.get(i).getPersonId());
				xljptIndexImport.setOperTime(param.get(i).getOperTime());
				xljptIndexImport.setStatus(param.get(i).getStatus());
				xljptIndexImport.setDataType(param.get(i).getDataType());
				xljptIndexImport.setScope(param.get(i).getScope());
				pJProjectMapper.indexImport(xljptIndexImport);
				xljptIndexImport2.setRowId(param.get(i).getRowId2());
				xljptIndexImport2.setIndexCode2(param.get(i).getIndexCode2());
				xljptIndexImport2.setFormulaNote(param.get(i).getFormulaNote());
				xljptIndexImport2.setIndexFormula(param.get(i).getIndexFormula());
				pJProjectMapper.indexImporDetail(xljptIndexImport2);
			}
		}
		return 1;
	}

	@Override
	public List<DrTable> upImport(List<Integer> param) {
		// TODO Auto-generated method stub
		pJProjectMapper.updateTableCode(param);
		return pJProjectMapper.upImport(param);
	}

	@Override
	public int insertTableLog(List<DrTable> param) {
		// TODO Auto-generated method stub
		for(int i=0;i<param.size();i++) {
			List<Integer> a=pJProjectMapper.existsSourceId(param.get(i).getRowId());
			if(a.size()==0) {
				DrTable drTable=new DrTable();
				drTable.setRowId(param.get(i).getRowId());
				drTable.setDeptId(param.get(i).getDeptId());
				drTable.setOperTime(param.get(i).getOperTime());
				pJProjectMapper.insertTableLog(drTable);
			}
		}
		return 1;
	}

	@Override
	public int insertUpTableLog(BsWorkflowLog param) {
		BsWorkflowLog bsWorkflowLog = new BsWorkflowLog();
		bsWorkflowLog.setPersonId(param.getPersonId());
		for(Integer a:param.getRowList()) {
			bsWorkflowLog.setSourceId(a);
			pJProjectMapper.insertUpTableLog(bsWorkflowLog);
		}
		return 1;
	}

	@Override
	public int updateCode(int param) {
		// TODO Auto-generated method stub
		return pJProjectMapper.updateCode(param);
	}


	@Override
	public int addVillage(PJVillage param, List<MultipartFile> fileList1) {
//		int num = pJProjectMapper.addProjectVillage(param);
		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());

		pJProjectMapper.addVillage(param);
		int rowId = pJProjectMapper.selectRowId(param.getProjectType());

		if (!CollectionUtils.isEmpty(fileList1)) {
			for (int i = 0; i < fileList1.size(); i++) {
				MultipartFile file = fileList1.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				bsAddition.setOrderType("1");
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}

	@Override
	public int addCar(PJProjectCar param, List<MultipartFile> fileList1) {

		pJProjectMapper.addCarProject(param);
		Integer rowId = param.getRowId();
//
		if (!CollectionUtils.isEmpty(fileList1)) {
			for (int i = 0; i < fileList1.size(); i++) {
				MultipartFile file = fileList1.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_car");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				bsAddition.setOrderType("1");
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}

	@Override
	public PJVillage queryVillage(int projectId) {
		return pJProjectMapper.queryVillage(projectId);
	}
	@Override
	public List<BsAddition> getFile(BsAddition param) {
		return pJProjectMapper.getFile(param);
	}
	@Override
	public int updateVillage(PJVillage param, List<List<MultipartFile>> list) {
		for (int i = 0; i < list.size(); i++) {
			if (!CollectionUtils.isEmpty(list.get(i))) {
				for (int j = 0; j < list.get(i).size(); j++) {
					MultipartFile file = list.get(i).get(j);
					String fileUrl = fileService.fileUpload(file);
					BsAddition bsAddition = new BsAddition();
					bsAddition.setAddType(1);
					bsAddition.setSourceTable("pj_project");
					bsAddition.setSourceId(param.getRowId());
					bsAddition.setAddName(file.getOriginalFilename());
					bsAddition.setAddUrl(fileUrl);
					bsAddition.setSequence(1);
					bsAddition.setStatus(1);
					bsAddition.setOrderType(i + 1 + "");
					pJProjectMapper.addBsAddition(bsAddition);
				}
			}
		}
		return pJProjectMapper.updateVillage(param);
	}
	@Override
	public int delProject(String projectId) {
		return pJProjectMapper.delProject(projectId);
	}

	@Override
	public int delFile(BsAddition param) {
		return pJProjectMapper.delFile(param);
	}
	@Override
	public List<PJProjectLogExtend> queryProjectLogExtendList(String projectId, String userType) {
		return pJProjectMapper.queryProjectLogExtendList(projectId, userType);
	}
	@Override
	public List<PJProject> getFatherProjectList(int deptId, String projectType) {
		return pJProjectMapper.getFatherProjectList(deptId, projectType);
	}
	@Override
	public List<PJProjectUnit> getPjProjectUnitList(String projectId) {
		return pJProjectMapper.getPjProjectUnitList(projectId);
	}
	@Override
	public void addWorkflowLog(BsWorkflowLog bsWorkflowLog, List<MultipartFile> fileList) {
		if (!CollectionUtils.isEmpty(fileList)) {
			bsWorkflowLog.setIsFile("1");
		}
		pJProjectMapper.addWorkflowLog(bsWorkflowLog);
		int index = pJProjectMapper.getWorkflowLogLastId();
		bsWorkflowLog.setWorkflowLogId(index);
		pJProjectMapper.addProjectLogExtend(bsWorkflowLog);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("bs_workflow_log");
				bsAddition.setSourceId(index);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
	}
	@Override
	public int projectLogExtendPass(String rowId) {
		return pJProjectMapper.projectLogExtendPass(rowId);
	}
	@Override
	public int projectLogExtendFail(String rowId, String workflowLogId, String projectId) {
		return pJProjectMapper.projectLogExtendFail(rowId, workflowLogId, projectId);
	}

	@Override
	public BsWorkflowLog getWorkflowLogObj(int rowId) {
		return pJProjectMapper.getWorkflowLogObj(rowId);
	}
	@Override
	public int addCollect(PJProjectCollect param, List<MultipartFile> fileList) {
		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());

		pJProjectMapper.addCollect(param);
		int rowId = pJProjectMapper.selectRowId("101");
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}

	@Override
	public int addTransport(PJProjectTransport param, List<MultipartFile> fileList) {
		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());
		pJProjectMapper.addTransport(param);
		int rowId = pJProjectMapper.selectRowId("102");
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}

	@Override
	public int addLandfill(PJProjectLandfill param, List<MultipartFile> fileList) {
		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());
		pJProjectMapper.addLandfill(param);
		int rowId = pJProjectMapper.selectRowId("105");
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}
	@Override
	public int addArchitecture(PJProjectBuild param, List<MultipartFile> fileList) {
		List<ParamKey> paramKeyList = paramKeyService.getParamKeyByKeyCode("centralPoint");
		param.setLng(paramKeyList.get(0).getKeyValue());
		param.setLat(paramKeyList.get(1).getKeyValue());
		pJProjectMapper.addArchitecture(param);
		int rowId = pJProjectMapper.selectRowId("106");
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(rowId);
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		return rowId;
	}

	@Override
	public PJProjectCollect queryCollect(String projectId) {
		PJProjectCollect project = pJProjectMapper.queryCollect(projectId);
		project.setUnitList(pJProjectMapper.queryUnitList(projectId));
		return project;
	}
	@Override
	public void updateCollect(PJProjectCollect param, List<MultipartFile> fileList) {
		pJProjectMapper.updateCollect(param);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(param.getRowId());
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
		pJProjectMapper.deleteUnit(param.getProjectId());
		for (PJProjectUnit projectUnit : param.getUnitList()) {
			projectUnit.setProjectId(param.getProjectId());
			projectUnit.setStatus(1);
			pJProjectMapper.addProjectUnit(projectUnit);
		}
	}
	@Override
	public PJProjectTransport queryTransport(String projectId) {
		return pJProjectMapper.queryTransport(projectId);
	}
	@Override
	public void updateTransport(PJProjectTransport param, List<MultipartFile> fileList) {
		pJProjectMapper.updateTransport(param);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(param.getRowId());
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
	}
	@Override
	public PJProjectLandfill queryLandfill(String projectId) {
		return pJProjectMapper.queryLandfill(projectId);
	}
	@Override
	public void updateLandfill(PJProjectLandfill param, List<MultipartFile> fileList) {
		pJProjectMapper.updateLandfill(param);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(param.getRowId());
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
	}
	@Override
	public PJProjectBuild queryArchitecture(String projectId) {
		return pJProjectMapper.queryArchitecture(projectId);
	}

	@Override
	public void updateArchitecture(PJProjectBuild param, List<MultipartFile> fileList) {
		pJProjectMapper.updateArchitecture(param);
		if (!CollectionUtils.isEmpty(fileList)) {
			for (int i = 0; i < fileList.size(); i++) {
				MultipartFile file = fileList.get(i);
				String fileUrl = fileService.fileUpload(file);
				BsAddition bsAddition = new BsAddition();
				bsAddition.setAddType(1);
				bsAddition.setSourceTable("pj_project");
				bsAddition.setSourceId(param.getRowId());
				bsAddition.setAddName(file.getOriginalFilename());
				bsAddition.setAddUrl(fileUrl);
				bsAddition.setSequence(1);
				bsAddition.setStatus(1);
				pJProjectMapper.addBsAddition(bsAddition);
			}
		}
	}
	@Override
	public List<Integer> getPjProjectUnit(int rowId) {
		return pJProjectMapper.getPjProjectUnit(rowId);
	}
	@Override
	public void relationCollect(BsRole params) {
		pJProjectMapper.deleteUnit(params.getRowId());
		for (int param : params.getMenuIds()) {
			if (param > 999999) {
				PJProjectUnit p = new PJProjectUnit();
				p.setProjectId(params.getRowId());
				p.setUnitId(param);
				p.setStatus(1);
				pJProjectMapper.addProjectUnit(p);
			}
		}
	}
	@Override
	public PageInfo<PJProjectLogExtend> getProjectLogExtendList(PJProjectLogExtend params) {
		PageHelper.startPage(params.getCurrentPage(), params.getPageSize());
		List<PJProjectLogExtend> list = pJProjectMapper.getProjectLogExtendList(params);
		PageInfo<PJProjectLogExtend> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}
	@Override
	public PJProjectCar queryCar(int rowId) {
		return pJProjectMapper.queryCar(rowId);
	}
	@Override
	public void setCarOne(int rowId) {
		pJProjectMapper.setCarOne(rowId);
	}
	@Override
	public List<PJProjectCar> queryAllCar() {
		return pJProjectMapper.queryAllCar();
	}
	@Override
	public PJProject queryProjectById(int rowId) {
		return pJProjectMapper.queryProjectById(rowId);
	}
	@Override
	public PJProjectCollect queryCollectProject(int projectId) {
		return pJProjectMapper.queryCollectProject(projectId);
	}
	@Override
	public PJProjectTransport queryTransportProject(int projectId) {
		return pJProjectMapper.queryTransportProject(projectId);
	}
	@Override
	public PJProjectBurn queryBurnProject(int projectId) {
		return pJProjectMapper.queryBurnProject(projectId);
	}
	@Override
	public PJProjectKitchen queryKitchenProject(int projectId) {
		return pJProjectMapper.queryKitchenProject(projectId);
	}
	@Override
	public PJProjectLandfill queryLandfillProject(int projectId) {
		return pJProjectMapper.queryLandfillProject(projectId);
	}
	@Override
	public PJProjectBuild queryBuildProject(int projectId) {
		return pJProjectMapper.queryBuildProject(projectId);
	}
	@Override
	public List<BsAddition> queryBsAddition(int sourceId) {
		return pJProjectMapper.queryBsAddition( sourceId);
	}
	@Override
	public void setProjectState(int rowId) {
		pJProjectMapper.setProjectState(rowId);
	}
	@Override
	public void setProjectState1(int id) {
		pJProjectMapper.setProjectState1(id);
	}
	@Override
	public void setProjectState2(int id) {
		pJProjectMapper.setProjectState2(id);
	}
	@Override
	public void setProjectState3(int id) {
		pJProjectMapper.setProjectState3(id);
	}
	@Override
	public void setProjectState4(int id) {
		pJProjectMapper.setProjectState4(id);
	}
	@Override
	public void setProjectState5(int id) {
		pJProjectMapper.setProjectState5(id);
	}
	@Override
	public void setProjectState6(int id) {
		pJProjectMapper.setProjectState6(id);
	}
	@Override
	public void setProjectState7(int id) {
		pJProjectMapper.setProjectState7(id);
	}
	@Override
	public List<PJProject> queryAllProject1(){
		return pJProjectMapper.queryAllProject1();
	}
	@Override
	public List<PJProjectCollect> queryAllCollect(){
		return pJProjectMapper.queryAllCollect();
	}
	@Override
	public List<PJProjectTransport> queryAllTransport(){
		return pJProjectMapper.queryAllTransport();
	}
	@Override
	public List<PJProjectBurn> queryAllBurn(){
		return pJProjectMapper.queryAllBurn();
	}
	@Override
	public List<PJProjectKitchen> queryAllKitchen(){
		return pJProjectMapper.queryAllKitchen();
	}
	@Override
	public List<PJProjectLandfill> queryAllLandfill(){
		return pJProjectMapper.queryAllLandfill();
	}
	@Override
	public List<PJProjectBuild> queryAllBuild(){
		return pJProjectMapper.queryAllBuild();
	}
	@Override
	public List<BsAddition> queryAllBsAddition(List<Integer> ids){
		List<BsAddition> listFile=new ArrayList();
		for(int i:ids) {
			List<BsAddition> list=pJProjectMapper.queryBsAddition(i);
			for(BsAddition bs:list) {
				listFile.add(bs);
			}
		}
		return listFile;
	}
	@Override
	public void setState(int rowId) {
		pJProjectMapper.setState(rowId);
	}
	@Override
	public void setState1(int id) {
		pJProjectMapper.setState1(id);
	}
	@Override
	public void setState2(int id) {
		pJProjectMapper.setState2(id);
	}
	@Override
	public void setState3(int id) {
		pJProjectMapper.setState3(id);
	}
	@Override
	public void setState4(int id) {
		pJProjectMapper.setState4(id);
	}
	@Override
	public void setState5(int id) {
		pJProjectMapper.setState5(id);
	}
	@Override
	public void setState6(int id) {
		pJProjectMapper.setState6(id);
	}
	//@Override
	//public void setState7(int id) {
	//	pJProjectMapper.setState7(id);
	//}
	@Override
	public PJProject queryProjectByParam(int id) {
		return pJProjectMapper.queryProjectByParam(id);
	}
	@Override
	public void setBsAdditionState(int id) {
		pJProjectMapper.setBsAdditionState(id);
	}
	@Override
	public List<BsWorkflowLog> queryWorkflowLog(int id) {
		return pJProjectMapper.queryWorkflowLog(id);
	}
	@Override
	public void setVillageState(int id) {
		pJProjectMapper.setVillageState(id);
	}
	@Override
	public void setWorkflowLogState(int id) {
		pJProjectMapper.setWorkflowLogState(id);
	}
	@Override
	public List<PJProject> queryAllProject2(){
		return pJProjectMapper.queryAllProject2();
	}
	@Override
	public List<PJVillage> queryAllVillage(){
		return pJProjectMapper.queryAllVillage();
	}
	@Override
	public List<BsWorkflowLog> queryAllWorkflowLog(List<Integer> id){
		List<BsWorkflowLog> listWorkflowLog=new ArrayList();
		for(int i:id) {
			List<BsWorkflowLog> list=pJProjectMapper.queryAllWorkflowLog(i);
			for(BsWorkflowLog bs:list) {
				listWorkflowLog.add(bs);
			}
		}

		return listWorkflowLog;
	}
	@Override
	public List<PJProject> queryAllProject3(){
		return pJProjectMapper.queryAllProject3();
	}
	@Override
	public void updateProject(PJProject project) {
		pJProjectMapper.updateProject2(project);
	}
	@Override
	public BsWorkflowLog getWorkflowLog(int rowId) {
		return pJProjectMapper.getWorkflowLog(rowId);
	}
	@Override
	public void insertWorkflowLogObj(BsWorkflowLog workflowLog) {
		pJProjectMapper.insertWorkflowLogObj(workflowLog);
	}
	@Override
	public void updateProjectState(int rowId) {
		pJProjectMapper.updateProjectState(rowId);
	}
	@Override
	public BsAddition queryBsAddition2(int id) {
		return pJProjectMapper.queryBsAddition2(id);
	}
	@Override
	public PJProjectLogExtend queryProjectLogExtend(int id) {
		return pJProjectMapper.queryProjectLogExtend(id);
	}
	@Override
	public void updateProjectLogExtend(PJProjectLogExtend pexd) {
		pJProjectMapper.updateProjectLogExtend(pexd);
	}
	@Override
	public void updateWorkflowLog2(BsWorkflowLog workflowLog) {
		pJProjectMapper.updateWorkflowLog2(workflowLog);
	}
	public void setTestState(int id) {
		pJProjectMapper.setTestState(id);
	}
	@Override
	public void setProjectStateTest(int rowId) {
		pJProjectMapper.setProjectStateTest(rowId);
	}
	@Override
	public List<PJProject> queryAllProject4(){
		return pJProjectMapper.queryAllProject4();
	}




	@Override
	public List<PJTableFour> queryTableFour(PJTableFour param) {
		return pJProjectMapper.queryTableFour(param);
	}

	@Override
	public List<DSVolumeScope> getTableThree(DSVolumeScope params) {

		return pJProjectMapper.getTableThree(params);
	}

	@Override
	public List<businessWeightMonth> getTableSix(businessWeightMonth params) {
		List<businessWeightMonth> tableSixTotal = getTableSixTotal(params);

		List<businessWeightMonth> tableSix = pJProjectMapper.getTableSix(params);
		for (int i = 0; i < tableSix.size(); i++) {
			setBWM(tableSix.get(i));
			if(tableSix.get(i).getType()==103){
				tableSix.get(i).setDesignAbilityBurn(tableSix.get(i).getDesignAbility());
				tableSix.get(i).setWeightMonthBurn(tableSix.get(i).getWeightMonth());
				tableSix.get(i).setWeightYearBurn(tableSix.get(i).getWeightYear());
				tableSix.get(i).setWeightMonthLastyearBurn(tableSix.get(i).getWeightMonthLastyear());
			}else if(tableSix.get(i).getType()==104){
				tableSix.get(i).setDesignAbilityKitchen(tableSix.get(i).getDesignAbility());
				tableSix.get(i).setWeightMonthKitchen(tableSix.get(i).getWeightMonth());
				tableSix.get(i).setWeightYearKitchen(tableSix.get(i).getWeightYear());
				tableSix.get(i).setWeightMonthLastyearKitchen(tableSix.get(i).getWeightMonthLastyear());
			}else if(tableSix.get(i).getType()==105){
				tableSix.get(i).setDesignAbilityLandfull(tableSix.get(i).getDesignAbility());
				tableSix.get(i).setWeightMonthLandfull(tableSix.get(i).getWeightMonth());
				tableSix.get(i).setWeightYearLandfull(tableSix.get(i).getWeightYear());
				tableSix.get(i).setWeightMonthLastyearLandfull(tableSix.get(i).getWeightMonthLastyear());
			}
		}
		if(tableSixTotal.size() != 0){
			businessWeightMonth businessWeightMonth = tableSixTotal.get(0);
			tableSix.add(0,businessWeightMonth);
		}
		return tableSix;
	}

	public void setBWM(businessWeightMonth bwm){
		bwm.setDesignAbilityBurn(0.0);
		bwm.setWeightMonthBurn(0.0);
		bwm.setWeightYearBurn(0.0);
		bwm.setWeightMonthLastyearBurn(0.0);
		bwm.setDesignAbilityKitchen(0.0);
		bwm.setWeightMonthKitchen(0.0);
		bwm.setWeightYearKitchen(0.0);
		bwm.setWeightMonthLastyearKitchen(0.0);
		bwm.setDesignAbilityLandfull(0.0);
		bwm.setWeightMonthLandfull(0.0);
		bwm.setWeightYearLandfull(0.0);
		bwm.setWeightMonthLastyearLandfull(0.0);
	}
	@Override
	public List<businessWeightMonth> getTableSixTotal(businessWeightMonth params) {
		List<businessWeightMonth> tableSixTotal = pJProjectMapper.getTableSixTotal(params);
		if(tableSixTotal.size() != 0 && tableSixTotal.get(0) != null){
			businessWeightMonth businessWeightMonth = tableSixTotal.get(0);
			businessWeightMonth.setDeptName("合计");
			businessWeightMonth.setOperationUnit("/");
			businessWeightMonth.setProcessingProcess("/");
		}

		return tableSixTotal;
	}

	@Override
	public List<DSVolumeTotal> getTableFive(DSVolumeTotal params) {

		return pJProjectMapper.getTableFive(params);
	}



	@Override
	public List<PJTableTwo> queryTableTwo(PJTableTwo param) {
		return pJProjectMapper.queryTableTwo(param);
	}

	@Override
	public Integer addProject(ProjectVO projectVO) {
		projectVO.setStartDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
		projectVO.setStatus("1");
		Integer i = pJProjectMapper.addProjectNew(projectVO);
		return i;
	}

	@Override
	public VillageDTO queryVillage1(int projectId) {
		return pJProjectMapper.queryVillage1(projectId);
	}

	@Override
	public Integer updateProject1(ProjectVO projectVO) {

		return pJProjectMapper.updateProject1(projectVO);
	}


	@Override
	public int updateCar1(PJProjectCar param, List<List<MultipartFile>> list) {
		for (int i = 0; i < list.size(); i++) {
			if (!CollectionUtils.isEmpty(list.get(i))) {
				for (int j = 0; j < list.get(i).size(); j++) {
					MultipartFile file = list.get(i).get(j);
					String fileUrl = fileService.fileUpload(file);
					BsAddition bsAddition = new BsAddition();
					bsAddition.setAddType(1);
					bsAddition.setSourceTable("pj_car");
					bsAddition.setSourceId(param.getRowId());
					bsAddition.setAddName(file.getOriginalFilename());
					bsAddition.setAddUrl(fileUrl);
					bsAddition.setSequence(1);
					bsAddition.setStatus(1);
					bsAddition.setOrderType(i + 1 + "");
					pJProjectMapper.addBsAddition(bsAddition);
				}
			}
		}
		return pJProjectMapper.updateCar1(param);
	}
}